package com.wanxi.test;
//二维数组，输入的所有元素的和

import java.util.Scanner;

public class ScannerTwoArray {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[][] array = new int[2][3];
        int length = array.length;
        System.out.println("请输入数据");
        int sum = 0;

        for (int i = 0; i < length; i++) {

            for (int j = 0; j < array[i].length; j++) {
                System.out.print("请输入第" + (i + 1) + "组的第" + (j + 1) + "个数据: ");
                array[i][j] = scanner.nextInt();
            }

        }

        for (int i = 0; i < length; i++) {

            for (int j = 0; j < array[i].length; j++) {
                sum += array[i][j];

                System.out.print(array[i][j] + " ");
            }
            System.out.println();

        }
        System.out.println("输入数据的和为： " + sum);

        scanner.close();
    }
}
